


var isdata=0;
var typedata;
var pagindex=0;
var pagesize=10;
var itemIndex = 0;

mui('body').on('tap','a',function(){document.location.href=this.href;});
function createFragment(me,itemIndex) {
    isdata=itemIndex;
    var data ;
    if (itemIndex=="0")
    {
        data ={
            status:1,
            pageindex:pagindex,
            pagesize:pagesize
        }
    }
    if (itemIndex=="1")
    {
        data ={
            status:2,
            pageindex:pagindex,
            pagesize:pagesize
        }
    }
    var result = '';
    mui.post('/Salary/findadmin', data, function (info) {
        console.log(info);
        var datas = info.object;
        if(datas.length === 0){
            me.lock();
            me.noData();
            me.resetload();
            return;
        }else {
            for (var i = 0; i < datas.length; i++) {
                cold = datas[i];
                if (cold['orderid']==null||cold['orderid']=="") {
                    result
                        += ''
                        + '    <hgroup class="khfxRow">'
                        + '      <header>申请时间：' + cold['createtime'] + '</header>'
                        + '      <div class="mid">'
                        + '        <img class="photo" src="' + cold['userimg'] + '" >'
                        + '        <span><label>订单号：</label>' + cold['id'] + '</span> '
                        + '        <span><label>类型：</label>' + gettixiatype(cold['type']) + '</span> '
                        + '        <span><label>状态：</label>' + gettixiastatus(cold['status']) + '</span> '
                        + '        <span><label>开户行：</label>' + cold["kaihuhang"] + '</span> '
                        + '        <span style="width: 100%!important;"><label>银行卡号：</label>' + cold['yinhangka'] + '</span> '
                        + '        <span><label>客户：</label>' + cold['nickname'] + '</span> '
                        + '        <span><label>金额：</label>' + cold['money'] + '</span> '
                        + '      </div>'
                        + '      <footer style="height: 40px;">' + admintixiabtn(cold['id'], cold['status']) + '</footer>'
                        + '    </hgroup>';
                }
            }
            $('.khfxPane').eq(itemIndex).append(result);


            if(datas.length %10!=0){
                me.$domDown.html(me.opts.domDown.domNoData);
            }
            else {
                me.resetload();
                pagindex=pagindex+10;
                me.$domDown.html(me.opts.domDown.domRefresh);
            }

        }

    });

};



$(function () {
    var itemIndex = 0;
    var tabLoadEndArray = [false, false, false];
    var tabScroolTopArray = [0, 0, 0];
    // dropload
    var dropload = $('.khfxWarp').dropload({
        scrollArea: window,
        domDown: {
            domClass: 'dropload-down',
            domRefresh: '<div class="dropload-refresh">上拉加载更多</div>',
            domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
            domNoData: '<div class="dropload-noData">已无数据</div>'
        },
        loadDownFn: function (me) {
            setTimeout(function () {
                createFragment(me, itemIndex);
            }, 500);
        }
    });


    $('.tabHead span').on('click', function () {

        tabScroolTopArray[itemIndex] = $(window).scrollTop();
        var $this = $(this);
        itemIndex = $this.index();
        $(window).scrollTop(tabScroolTopArray[itemIndex]);

        pagindex=0;
        pagesize=10;

        $('.khfxPane hgroup').remove();
        $(this).addClass('active').siblings('.tabHead span').removeClass('active');
        $('.tabHead .border').css('left', $(this).offset().left + 'px');
        $('.khfxPane').eq(itemIndex).show().siblings('.khfxPane').hide();

        if (!tabLoadEndArray[itemIndex]) {
            dropload.unlock();
            dropload.noData(false);
        } else {
            dropload.lock('down');
            dropload.noData();
        }
        dropload.resetload();
    });
});